/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package group2assignone.ucm.manager;

import group2assignone.dao.MyDAO;
import group2assignone.ucm.UCController;
import group2assignone.ucm.UCStartup;
import group2assignone.view.UITool;
import group2assignone.view.manager.DeleteAirportView;
import group2assignone.view.manager.ManagerView;

/**
 *
 * @author Natalie
 */
public class UCDeleteAirport implements UCController
{
    private DeleteAirportView view;

    public UCDeleteAirport(DeleteAirportView view)
    {
        this.view = view;
    }
    
    public void run()
    {
        if (view.getSelectedRow() >= 0) {  //if have selection

            String airportLoc = view.getAirportLoc();

            MyDAO coms = UCStartup.getInstance().getDAO();
            boolean worked = coms.sQLDeleteAirport(airportLoc);

            view.dispose();
            ManagerView manView = ManagerView.getInstance();
            //manView.setUsername(man.getUsername());
            manView.go();

        } else {
            UITool.displayError("Select a Airport to Delete!!!", view);
        }
    }

}
